package Iol;

import java.io.*;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.19.17.38
 */
public class Io5 {
    public static void main(String[] args) {
        String src="src.txt";
        try(var r=new BufferedReader(new FileReader(src))) {
        int num=0;
        while (r.ready()){
            String line=String.format("%04d%s",++num,r.lines());
            append(line,new File("scr2.txt"));
        }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void append(String source, File dst){
        try(var out=new BufferedWriter(new FileWriter(dst,true))) {
            out.write(source);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
